<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 题目1(选做)：const arr=['name','age','hhh','hhh','age','hhh','hhh','hhh'] 元素各出现多少次
// 要求输出一个对象如下：{age: 2,hhh: 5,name: 1}
const arr = ['name', 'age', 'hhh', 'hhh', 'age', 'hhh', 'hhh', 'hhh']
const obj = {}
arr.forEach(item=>{
  if(obj[item]){
    obj[item]++
  }else{
    obj[item] = 1 
  }
})
console.log(obj);
  </script>
</body>
</html>